import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
// import './assets/fonts/iconfont.css'
//导入全局样式表
import './assets/css/global.css'
//导入树形列表插件
import TreeTable from 'vue-table-with-tree-grid'
//导入富文本编辑器
import VueQuillEditor from'vue-quill-editor'
//导入富文本样式
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
//导入axios
import axios from 'axios'
//设置axios请求根路径
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
//设置axios拦截器，给需要权限的请求的请求头加token
axios.interceptors.request.use(config => {
  //config是axios封装好的对象。包括请求头响应吗之类的
  //给请求头加token
  config.headers.Authorization = window.sessionStorage.getItem('token')
  //固定写法，要返回config
  return config
})
//把axios挂载到vue的原型上的$http上
Vue.prototype.$http = axios



//默认配置
Vue.config.productionTip = false
//注册树形列表组件
Vue.component('treetable', TreeTable);
//注册富文本编辑器
Vue.use(VueQuillEditor)

//定义时间过滤器
Vue.filter('dateFormat', function (originVal) {
  const dt = new Date(originVal)
  var y = dt.getFullYear()
  var m = (dt.getMonth() + 1 + '').padStart(2, '0')
  var d = (dt.getDate() + '').padStart(2, '0')

  var h = (dt.getHours() + '').padStart(2, '0')
  var f = (dt.getMinutes() + '').padStart(2, '0')
  var s = (dt.getSeconds() + '').padStart(2, '0')
  return `${y}-${m}-${d} ${h}:${f}:${s}`
})

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
